package com.dangf.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * 拦截器，验证 token
 * 
 * @author Hello_海生
 * @date 2014年3月27日
 */
public class TokenInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		// 设置 JSON 不使用 循环引用

		//JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
		// Format formatter = new SimpleDateFormat("yyyy-MM-dd");

		// String serverKey="DangF+"+formatter.format(new Date())+"+DangF";

		// serverKey=getMd5(serverKey);

		System.out.println("请求地址:"+request.getServletPath());

		/*
		if (request.getParameter("token") == null|| "".equals(request.getParameter("token")))return false;
		else if (request.getServletPath().indexOf("/user/") > -1){
			//查询数据库
			return false;
		}else if(Md5Utils.encryptionFor32("DangF.COM").equals(request.getParameter("token"))){
			return true;
		}
		
		//if (request.getParameter("key").equals("DangF"))return true;
		//return false;
		return true;
		*/
	
		
		return true;

	}
}